package cn.humaohua.study.yanmo_design_pattern.ch20.v2;

import java.util.ArrayList;
import java.util.List;

public class UnsharedConcreteFlyweight implements Flyweight {
    //记录每个组合对象所包含的子组件
    private List<Flyweight> list = new ArrayList<>();

    @Override
    public boolean match(String securityEntity, String permit) {
        for (Flyweight flyweight : list) {
            if (flyweight.match(securityEntity, permit))
                return true;
        }
        return false;
    }

    @Override
    public void add(Flyweight flyweight) {
        list.add(flyweight);
    }
}
